package jmc.util;



import java.io.File;
import java.util.HashMap;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;

import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;


public class ParseXmlSheet {

	private static ParseXmlSheet parseXmlSheet;
	private HashMap<String,String> validaciones = null;	
	

	private ParseXmlSheet(){
		//validaciones = new HashMap<String,String>();
	}

	
	
	public static void loadTfdeba00(String data){
		  
		try {		  
			  DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
			  DocumentBuilder db = dbf.newDocumentBuilder();
			  Document doc = db.parse(new File("c://ExampleSheet.xml"));
			  doc.getDocumentElement().normalize();
			  System.out.println("Root element " + doc.getDocumentElement().getNodeName());			  
			  
			  NodeList dataList = doc.getElementsByTagName("data");
			  
			  
				  //Leo el Tag Data	  
				  Node dataNode = dataList.item(0);
				  
				  NodeList rowList = dataNode.getChildNodes();
				  //Leo una Fila
				  for(int r = 0; r < rowList.getLength(); r++){
					  //Leo las Fila	  
					  Node rowNode = rowList.item(r);
					  System.out.println("Nombre Row: " + rowNode.getNodeName());
					  NodeList columnList = rowNode.getChildNodes();
					  for(int c = 0; c < columnList.getLength(); c++){
						  //Leo Las columnas
						  Node columnNode = columnList.item(c);
						  System.out.println("Nombre Column: " + columnNode.getNodeName());
						  System.out.println("Valor Column: " +columnNode.getTextContent());
						  System.out.println("Type Column: " +columnNode.getNodeType());
						  
					  }
					  
					  
					  
				  }
				  

			  
			  } catch (Exception e) {
			    e.printStackTrace();
			  }	 
	 
		}
	
	public static void main(String[] args) {
		//loadTfdeba00("<?xml version=\"1.0\" encoding=\"UTF-8\"?><documents><document title=\"\"><metadata><columns>5</columns><rows>15</rows><col_widths><c0>120</c0><c1>120</c1><c2>120</c2><c3>120</c3><c4>120</c4></col_widths></metadata><data><r0 h=\"18px\"><c0>asda</c0><c1></c1><c2></c2><c3></c3><c4></c4></r0><r1 h=\"18px\"><c0></c0><c1></c1><c2></c2><c3></c3><c4></c4></r1><r2 h=\"18px\"><c0>asda</c0><c1></c1><c2></c2><c3></c3><c4></c4></r2><r3 h=\"18px\"><c0></c0><c1></c1><c2></c2><c3></c3><c4></c4></r3><r4 h=\"18px\"><c0></c0><c1></c1><c2></c2><c3></c3><c4></c4></r4><r5 h=\"18px\"><c0>ada</c0><c1></c1><c2></c2><c3></c3><c4></c4></r5><r6 h=\"18px\"><c0></c0><c1></c1><c2></c2><c3></c3><c4></c4></r6><r7 h=\"18px\"><c0></c0><c1></c1><c2></c2><c3></c3><c4></c4></r7><r8 h=\"18px\"><c0></c0><c1></c1><c2></c2><c3></c3><c4></c4></r8><r9 h=\"18px\"><c0></c0><c1></c1><c2></c2><c3></c3><c4></c4></r9><r10 h=\"18\"><c0></c0><c1></c1><c2></c2><c3></c3><c4></c4></r10><r11 h=\"18\"><c0></c0><c1></c1><c2></c2><c3></c3><c4></c4></r11><r12 h=\"18\"><c0></c0><c1></c1><c2></c2><c3></c3><c4></c4></r12><r13 h=\"18\"><c0></c0><c1></c1><c2></c2><c3></c3><c4></c4></r13><r14 h=\"18\"><c0></c0><c1></c1><c2></c2><c3></c3><c4></c4></r14></data></document></documents>");
		loadTfdeba00("<?xml version=\"1.0\" encoding=\"UTF-8\"?><actions><entry><url>serviceSendMail</url><rolEnable>0</rolEnable></entry><entry><url>facturar</url><rolEnable>0</rolEnable></entry><entry><url>getFacturaAs</url><rolEnable>0</rolEnable></entry></actions>"	);
		
		
	}
	
}
